/*
 * Copyright (c) 2009, D. Adam Karim <adam@akarsoft.com>
 * 
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#import <Foundation/Foundation.h>

#import <curses.h>

#define	OCColorBlack	COLOR_BLACK
#define	OCColorRed		COLOR_RED
#define	OCColorGreen	COLOR_GREEN
#define	OCColorYellow	COLOR_YELLOW
#define	OCColorBlue		COLOR_BLUE
#define	OCColorMagenta	COLOR_MAGENTA
#define	OCColorCyan		COLOR_CYAN
#define	OCColorWhite	COLOR_WHITE


typedef struct {
	int pair;
	int foreground;
	int background;
} OCColorPair;

@interface OCWindow : NSObject {
	WINDOW *window;
	OCWindow *parent;
	NSMutableArray *subWindows;
	NSArray *siblings;
	BOOL hasColors;
	int backgroundColor;
}

@property (readwrite, assign) WINDOW *window;
@property (readwrite, retain) OCWindow *parent;
@property (readwrite, retain) NSMutableArray *subWindows;
@property (readwrite, retain) NSArray *siblings;
@property (readwrite, assign) int backgroundColor;

- (id)initWithWindow:(WINDOW *)win;
- (id)initWithParent:(OCWindow *)win location:(NSRect)location absolute:(BOOL)absolute;

- (void)initializer;

- (void)deleteSubWindow:(OCWindow *)subWindow;

- (int)length;
- (int)width;

- (void)clear;
- (void)refresh;

- (int)printToWindow:(NSString *)format,...;
- (int)printToWindowAtPoint:(NSPoint)point format:(NSString *)format,...;
- (int)printToWindowWithFormat:(NSString *)format arguments:(va_list)arguments;
- (int)printToWindowAtPoint:(NSPoint)point format:(NSString *)format arguments:(va_list)arguments;

- (int)scanFromWindow:(NSString *)format,...;
- (int)scanFromWindowAtPoint:(NSPoint)point format:(NSString *)format,...;
- (int)scanFromWindowWithFormat:(NSString *)format arguments:(va_list)arguments;
- (int)scanFromWindowAtPoint:(NSPoint)point format:(NSString *)format arguments:(va_list)arguments;

- (void)setKeyboard;

- (BOOL)useColors;
- (void)setColorPair:(OCColorPair)pair;

- (void)box;
@end

OCColorPair OCMakeColorPair(int pair, int foreground, int background);